export const formatName = (name: string | undefined) => {
  if (!name) return '';

  // 优先处理UUID前缀（格式：8-4-4-4-12）
  const uuidRegex = /^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}-/i;
  if (uuidRegex.test(name)) {
    // 找到最后一个'-'的位置
    const lastDashIndex = name.lastIndexOf('-');
    let processed = name.slice(lastDashIndex + 1);

    // 去除扩展名
    const dotIndex = processed.lastIndexOf('.');
    if (dotIndex > 0) {
      processed = processed.slice(0, dotIndex);
    }
    return processed;
  }

  // 处理时间戳前缀（第一个'-'前是纯数字）
  const firstDashIndex = name.indexOf('-');
  if (firstDashIndex > 0 && /^\d+$/.test(name.slice(0, firstDashIndex))) {
    let processed = name.slice(firstDashIndex + 1);

    const dotIndex = processed.lastIndexOf('.');
    if (dotIndex > 0) {
      processed = processed.slice(0, dotIndex);
    }
    return processed;
  }

  // 其他情况保留原名称
  return name;
};

